//
//  UIImageView+RxExtection.swift
//  YKSwiftRxExtection
//
//  Created by edward on 2022/1/10.
//

import UIKit
import RxSwift

extension Reactive where Base: UIImageView {
    
    public func image() -> Binder<UIImage?> {
        Binder(self.base) { imageView, image in
            imageView.image = image
        }
    }
    
    
    public func name() -> Binder<String?> {
        Binder(self.base) { imageView, name in
            if let n = name {
                if let systemImage = UIImage.init(systemName: n) {
                    imageView.image = systemImage
                }else if let image = UIImage.init(named: n) {
                    imageView.image = image
                }
            }
        }
    }
}
